var table ,form ,laypage ,layer ,element ,laydate ,upload//时间组件
var map = new AMap.Map("container", {
	//center:[107.395792,40.73185],
	mapStyle: "amap://styles/d9a4d61b09a20fbf4f9ea53a37a7c11b",
	zoom: 18
});
$(function(){
    layui.use(['table','form','laypage','layer', 'element', 'laydate','upload','laytpl'], function(){
    	table = layui.table;
        form=layui.form;
        laypage = layui.laypage ;//分页
        layer = layui.layer ;//弹层
        element = layui.element; //元素操作
        laydate = layui.laydate; //时间组件 
        upload = layui.upload;
        laytpl = layui.laytpl; 
        
        getheaderFUN()//获取头部
        statisticsAge("dengji");///*最近七日告警等级比例*/
        statisticsQushi("gaojing");//近7日告警统计
      //故障处理简报
/*        element.progress('DLGZ', '50%');    
        setInterval(function(){
        	element.progress('DLGZ', '50%');
        },5000);*/
              
        //全屏
        var a = 0;
		$('#fullscreen').on('click', function () {
			a++;
			a % 2 == 1 ? enterfullscreen() : exitfullscreen();
		});
        
    });
});
///*最近七日告警等级比例*/
function statisticsAge(model){
	var myChart = echarts.init(document.getElementById(model));
	// 指定图表的配置项和数据
	var option = {
		    legend: {
		    	textStyle:{
 	                color:'#1bdcef',
 	        　　　　                fontSize:10,
 	            },
		        top: 'top'
		    },
		    grid: {
		        top: 10,
		    },
		    tooltip : {  
	            trigger: 'item',  
	            formatter: "{c}%"  
	        },
		    series: [
		        {
		            name: '面积模式',
		            type: 'pie',
		            radius: ['25%', '50%'],
		            center: ['50%', '50%'],
		            roseType: 'area',
		            itemStyle: {
		                borderRadius: 5
		            },
		            label: {
			            normal: {
			            	textStyle:{
				        		color:'#00ffff'
				        	},
				        	show: true,
			        		formatter: "{c}%"
			            },
			        },
		            data: [
		                {value: 40, name: '告知'},
		                {value: 38, name: '变位'},
		                {value: 32, name: '维修'},
		                {value: 30, name: '异常'},
		                {value: 28, name: '故障'},
		            ]
		        }
		    ]
    };
	// 使用刚指定的配置项和数据显示图表。
	myChart.setOption(option,true);
    setInterval(function(){
    	myChart.clear();
    	myChart.setOption(option,true);
    },5000);
}
//近7日告警统计
function statisticsQushi(model){
	var myChart2 = echarts.init(document.getElementById(model));
	var option = {
			   grid: {
					left: 50,
					right: 30,
					top:15,
					bottom: 40
				},
				tooltip : {
				         trigger: 'axis', //触发类型,'item'图形，散点图，饼图等无类目轴的图表中。 'axis'柱状图，折线图等。
				         triggerOn:"mousemove",  //提示框触发的条件
				         showContent:true,//是否显示提示框浮层
				         formatter: "{b} : 用电量{c}(KW)"
				},
			    xAxis: {
					type: 'category',
					boundaryGap: false,
					boundaryGap:true,
			        splitLine:{ //网格线
			          show:true,
			          lineStyle: {
							color: 'rgba(5,77,169,1)'
						}
			        },
			        axisLabel: { //x坐标文字样式
			        	color: "rgba(0,168,233,1)",
			        	interval: 0,//横坐标数据都显示
			        },
			        axisLine: {//X轴样式
						show:true,
						lineStyle: {
							color: 'rgba(5,77,169,1)'
						}
					},
					data:['4.27', '4.28', '4.29', '4.30', '5.1', '5.2', '5.3', '5.4']
				},
				yAxis: {
					type: 'value',
					axisLine: {
						show:true,
						lineStyle: {
							color: 'rgba(5,77,169,1)'
						}
					},
					splitLine: {
						lineStyle: {
							color: 'rgba(5,77,169,1)'
						}
					},
					axisLabel: {
						color: "rgba(0,168,233,1)"
					},
				},
			    series: [{
			        data: ["2","5","3","2","0","3","1","7"],
			        barWidth : 20,//柱图宽度
			        type: 'bar',
			        barWidth : 10,//柱图宽度
				    itemStyle: {
				    	normal: {
							color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
								offset: 0,
								color: "#2092f5" // 0% 处的颜色
							}, {
								offset: 0.3,
								color: "#2092f5" // 60% 处的颜色
							}, {
								offset: 1,
								color: "#09d8fd" // 100% 处的颜色
							}], false)
						}
	                }
			    }]                    
	};
	myChart2.setOption(option,true);
    setInterval(function(){
    	myChart2.clear();
    	myChart2.setOption(option,true);
    },5500);
}
//控制全屏
function enterfullscreen() { //进入全屏
	$("#fullscreen").html("<i class='layui-icon'>&#xe758;</i>退出全屏");
	var docElm = document.documentElement;
	var elm = document.getElementById('Main');
	//W3C
	if (docElm.requestFullscreen) {
		docElm.requestFullscreen();
	}
	//FireFox
	else if (docElm.mozRequestFullScreen) {
		docElm.mozRequestFullScreen();
	}
	//Chrome等
	else if (docElm.webkitRequestFullScreen) {
		docElm.webkitRequestFullScreen();
	}
	//IE11
	else if (elm.msRequestFullscreen) {
		elm.msRequestFullscreen();
	}
}

function exitfullscreen() { //退出全屏
	$("#fullscreen").html("切换全屏");
	if (document.exitFullscreen) {
		document.exitFullscreen();
	} else if (document.mozCancelFullScreen) {
		document.mozCancelFullScreen();
	} else if (document.webkitCancelFullScreen) {
		document.webkitCancelFullScreen();
	} else if (document.msExitFullscreen) {
		document.msExitFullscreen();
	}
}